<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>父子组件传值</title>
  <script src="vue.js"></script>
</head>
<body>
<!--父传子-->
<!--单向数据流：父组件向子组件传递参数  但子组件不可修改  父组件传递的内容-->
<!--若要改变父组件传的值data:function () {return {number:this.count}},-->
<!--父通过属性的方式传值-->
<div id="app">
       <counter :count="0"></counter>
       <counter :count="3"></counter>
</div>
<script>
  var counter={
    props:['count'],
    data:function () {
      return {
        number:this.count
      }
    },
    template:'<div @click="handleClick">{{number}}</div>',
    methods:{
      handleClick:function(){
            this.number ++
      }
    }
  }
  var vm=new Vue({
    el:"#app",
    components:{
        counter:counter
    }
  })
</script>
</body>
</html>
